#pragma once

#include "pch.h"
#include "prerequisites.h"
#include "resource.h"
#include "vector4.h"
#include "matrix4x4.h"

class c_material : public c_resource
{
    friend material_ptr create_material_from_effect_file(const std::string&); 
    
public:
    ~c_material(); 
    
    d3dx_effect_ptr& get_d3dx_effect_ptr() { return m_d3dx_effect; }
    
    void set_world_view_proj(const c_matrix4x4& mat_world, const c_matrix4x4& mat_view, const c_matrix4x4& mat_proj); 
    void set_camera_params(const camera_ptr& cam_ptr);
    
    void set_diffuse_texture(unsigned int unit, const texture_ptr& tex);

    unsigned int begin_effect();
    void end_effect(); 
    void begin_pass(const unsigned int pass); 
    void end_pass();
    
private:
    c_material(const d3dx_effect_ptr&);

private:

    d3dx_effect_ptr m_d3dx_effect;
    D3DXHANDLE m_params_block; 

    typedef std::vector<D3DXHANDLE> handle_vec_t;
    handle_vec_t m_diffuse_textures;
};

material_ptr make_default_material(); 